// ==UserScript==
// @name         隐藏B站直播网页全屏聊天
// @description  隐藏网页全屏时右侧烦躁的聊天窗口，最好用较新一点的浏览器
// @namespace    yinghuaile
// @license      MIT
// @grant        GM_addStyle
// @version      1.0
// @author       yinghuaile
// @match        https://live.bilibili.com/*
// ==/UserScript==

(function () {
    var body = document.body;
    var rightBar;
    var findRightBarTimer;
    var findRightBar = function () {
        rightBar = document.querySelector("#aside-area-vm");
        if (rightBar != null) {
            GM_addStyle(
                ".player-full-win .player-section{width:100% !important;}"
            );
            clearInterval(findRightBarTimer);
        }
    };

    findRightBarTimer = setInterval(findRightBar, 1000);

    var testObserver = new MutationObserver(function (mutations) {
        try {
            if (rightBar == null) {
                return;
            }
            if (body.className.replace(/\s/g, "") == "supportWebp") {
                rightBar.style.display = "block";
            } else {
                rightBar.style.display = "none";
            }
        } catch (error) {}
    });
    testObserver.observe(body, {
        attributeFilter: ["class"],
    });
})();
